package com.jin.controller;

import com.jin.config.MessageConfig.Message;
import com.jin.pojo.ApproveInfo;
import com.jin.service.ApproveInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "审批表模块")
@RestController
@RequestMapping("/approveInfo")
@CrossOrigin
public class ApproveInfoController {

    @Autowired
    ApproveInfoService approveInfoService;
    //g

    @ApiOperation(value = "添加审批表")
    @PostMapping("/insertApproveInfo")
    public Message insertApproveInfo(ApproveInfo approveInfo) {
        return approveInfoService.insertApproveInfo(approveInfo)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }

    @ApiOperation(value = "删除审批表")
    @DeleteMapping("/deleteApproveInfo")
    public Message deleteApproveInfo(Integer id) {
        return approveInfoService.deleteApproveInfo(id)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }

    @ApiOperation(value = "更新审批表")
    @PutMapping("/updateApproveInfo")
    public Message updateApproveInfo(ApproveInfo approveInfo) {
        return approveInfoService.updateApproveInfo(approveInfo)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }

    @ApiOperation(value = "根据ID查询审批表")
    @GetMapping("/getApproveInfoById")
    public Message getApproveInfoById(Integer id) {
        return Message.success("200").add(approveInfoService.getApproveInfoById(id));
    }

    @ApiOperation(value = "查询全部审批表")
    @GetMapping("/getApproveInfos")
    public Message getApproveInfos() {
        return Message.success("200").add(approveInfoService.getApproveInfos());
    }
}
